package Collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class GenericDemo {
    public static void main(String[] args) {
        Collection<Point> c=new ArrayList<>();
        c.add(new Point(1,2));
        c.add(new Point(3,4));
        c.add(new Point(5,6));
        c.add(new Point(7,8));
        c.add(new Point(9,0));
        Iterator<Point> it=c.iterator();
        while(it.hasNext()){
            Point p=it.next();
            System.out.println(p);
        }
        for (Point p:c){
            System.out.println(p);
        }
        Collection<String> a=new ArrayList<>();
        a.add("one");
        a.add("two");
        a.add("three");
        a.add("four");
        a.add("five");
        Iterator<String> ite=a.iterator();
        while (ite.hasNext()){
            String s1=ite.next();
            System.out.println(s1);
        }
        for (String str:a){
            System.out.println(str);
        }
    }

}
